$(document).ready(function() 
{
	//
	$('#main-menu li').hover(
		// Mouse In
		function () {
			//$(this).addClass("hover");
			$(this).find('.submenu').show();
		},
		// Mouse Out
		function () {
			//$(this).removeClass("hover");
			$(this).find('.submenu').hide();
		}
	);
	
	//
	$('#language').click(function(e){
		e.stopPropagation();
		SelectLanguage();
	});
	
	//
	$('#language a.selected').click(function(e){
		e.stopPropagation();
		SelectLanguage();
		return false;
	});
	
	//
	$('#header #notifications #notificationsTrigger span').click(function(e){
		e.stopPropagation();
		var status = $('#header #notifications').attr('class');
		if (status === 'show') {
			$('#header #notifications').removeClass('show');
		}
		else {
			$('#header #notifications').addClass('show');
		}
	});
	
	//
	$('#header #notifications').click(function(e){
		e.stopPropagation();
	});
	
	//
	$(document).click(function() {
		$('#header #notifications').removeClass('show');
		$('#language #select-language').removeClass('show');
	});
	
	//
	$('#mapCopy #expand').click(function(e){
		e.stopPropagation();
		var status = $(this).attr('class');
		if (status === 'expanded') {
			$(this).removeClass('expanded');
			$('#mapContainer #map').removeClass('expanded');
			resizeMap();
		}
		else {
			$(this).addClass('expanded');
			$('#mapContainer #map').addClass('expanded');
			resizeMap();
		}
	});
	
	//
	$('#nearbyRex .hideNearbyRex').click(function(e){
		$('#nearbyRex').fadeOut();
	});
	
	//
	$('#newsFlash .newsFlashNext').click(function(e){
		var promo = $('#newsFlash #promos .promo');
		var n = 0;
		$(promo).each(function(index) {
			if ($(this).css('display') === 'block') {
				n = index;
			}
		});
		if (promo.length > 0) {
			$('#newsFlash .newsFlashPrev').removeClass('faded');
		}
		if (n+2 === promo.length) {
			$('#newsFlash .newsFlashNext').addClass('faded');
		}
		if (n+1 < promo.length) {
			$(promo[n]).css('display', 'none');
			$(promo[n+1]).css('display', 'block');
		}
	});
	
	//
	$('#newsFlash .newsFlashPrev').click(function(e){
		var promo = $('#newsFlash #promos .promo');
		var n = 0;
		$(promo).each(function(index) {
			if ($(this).css('display') === 'block') {
				n = index;
			}
		});
		if (n-1 === 0) {
			$('#newsFlash .newsFlashPrev').addClass('faded');
		}
		if (n < promo.length) {
			$('#newsFlash .newsFlashNext').removeClass('faded');
		}
		if (n-1 >= 0) {
			$(promo[n]).css('display', 'none');
			$(promo[n-1]).css('display', 'block');
		}
	});
});

////
//function initializeGoogleMaps(x, y, zoom, id) {
//	var mapOptions = {
//		center: new google.maps.LatLng(x, y),
//		zoom: zoom,
//		mapTypeId: google.maps.MapTypeId.ROADMAP
//	};
//	var map = new google.maps.Map(document.getElementById(id), mapOptions);
//}

function SelectLanguage() {
	var status = $('#language #select-language').attr('class');
	if (status === 'show') {
		$('#language #select-language').removeClass('show');
	}
	else {
		$('#language #select-language').addClass('show');
	}
}